package br.uff.busuffweb.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author jthiago
 */
@NamedQueries({
    @NamedQuery(name = "OnibusCircuito.getTodos",
    query = "select o from OnibusCircuito o order by o.id"),
    
    @NamedQuery(name = "OnibusCircuito.getPorOnibus",
    query = "select oc from OnibusCircuito oc " +
            " where oc.onibus = ?"),
    
    @NamedQuery(name = "OnibusCircuito.getPorCircuito",
    query = "select oc from OnibusCircuito oc " +
            " where oc.circuito = ?"),
        
    @NamedQuery(name = "OnibusCircuito.getPorOnibusECircuito",
    query = "select oc from OnibusCircuito oc " +
            " where oc.onibus = ? and oc.circuito = ?"),
    
    @NamedQuery(name = "OnibusCircuito.getPorOnibusEDataInicio",
    query = "select oc from OnibusCircuito oc " +
            " where oc.onibus = ? and oc.data_hora_inicio = ?")
})
@Entity
@SequenceGenerator(sequenceName = "seq_onibusCircuito", name = "Sequencia")
@Table(name = "onibusCircuito")
public class OnibusCircuito implements Serializable {
    
    @Id
    @GeneratedValue(generator = "Sequencia", strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne
    @JoinColumn(name="idOnibus")
    private Onibus onibus;
    
    @ManyToOne
    @JoinColumn(name="idCircuito")
    private Circuito circuito;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date data_hora_inicio;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date data_hora_fim;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Onibus getOnibus() {
        return onibus;
    }

    public void setOnibus(Onibus onibus) {
        this.onibus = onibus;
    }

    public Circuito getCircuito() {
        return circuito;
    }

    public void setCircuito(Circuito circuito) {
        this.circuito = circuito;
    }

    public Date getData_hora_inicio() {
        return data_hora_inicio;
    }

    public void setData_hora_inicio(Date data_hora_inicio) {
        this.data_hora_inicio = data_hora_inicio;
    }

    public Date getData_hora_fim() {
        return data_hora_fim;
    }

    public void setData_hora_fim(Date data_hora_fim) {
        this.data_hora_fim = data_hora_fim;
    }
}
